<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // // 带有参数的函数
    // function getSum(end) {
    //   let sum = 0
    //   for (let i = 1; i <= end; i++) {
    //     sum += i

    //   }
    //   console.log(sum)
    // }
    // getSum(50)
    // getSum(100)
    // 默认参数，比较严谨
    function getSum(start = 0, end = 0) {
      let sum = 0
      for (let i = start; i <= end; i++) {
        sum += i

      }
      console.log(sum)
    }
    getSum(1, 50)
    getSum(100, 102)


  </script>
</body>

</html>